// API类型定义文件
import { MediaType, MediaCategory } from './index';
export interface BaseResponse<T = any> {
  code: number;
  message: string;
  data: T;
  timestamp: number;
}

export interface PaginationResponse<T = any> {
  records: T[];
  total: number;
  size: number;
  current: number;
  pages: number;
}

// 认证相关类型
export interface LoginRequest {
  username: string;
  password: string;
}

export interface LoginResponse {
  userId: number;
  nickname: string;
  username: string;
  role: number;
  roleName: string;
}

// 用户相关类型
export interface UserInfo {
  userId: number;
  nickname: string;
  username: string;
  phone?: string;
  email?: string;
  role: number;
  roleName: string;
  status: number;
  statusName: string;
  createTime: string;
  updateTime: string;
}

export interface UserRequest {
  userId?: number;
  nickname: string;
  username: string;
  password: string;
  phone?: string;
  email?: string;
  role: number;
  status: number;
}

export interface UserQueryParams {
  current: number;
  size: number;
  userId?: number;
  nickname?: string;
  username: string;
  password: string;
  phone?: string;
  email?: string;
  role?: number;
  status?: number;
}

// 车辆相关类型
export interface CarInfo {
  carId: number;
  title: string;
  carNo: string;
  model?: string;
  carType: string;
  carTypeName: string;
  price: number;
  color?: string;
  size?: string;
  weight?: number;
  brand?: string;
  energyType?: string;
  fuelConsumption?: number;
  rangeKm?: number;
  mileage?: number;
  productionRegion?: string;
  batteryType?: string;
  productionYear?: number;
  maxTorque?: number;
  maxPower?: number;
  stock: number;
  status: number;
  statusName: string;
  createTime: string;
  updateTime: string;
}

export interface CarRequest {
  carId?: number;
  title: string;
  carNo: string;
  model?: string;
  carType?: string;
  price?: number;
  color?: string;
  size?: string;
  weight?: number;
  brand?: string;
  energyType?: string;
  fuelConsumption?: number;
  rangeKm?: number;
  mileage?: number;
  productionRegion?: string;
  batteryType?: string;
  productionYear?: number;
  maxTorque?: number;
  maxPower?: number;
  stock: number;
  status?: number;
}

export interface CarQueryParams {
  current: number;
  size: number;
  carId?: number;
  title: string;
  carNo: string;
  model?: string;
  carType?: string;
  price?: string;
  color?: string;
  dimensions?: string;
  weight?: number;
  brand?: string;
  energyType?: string;
  fuelConsumption?: string;
  rangeKm?: number;
  mileage?: number;
  productionRegion?: string;
  batteryType?: string;
  productionYear?: number;
  maxTorque?: number;
  maxPower?: number;
  stock: number;
  status?: number;
}

// 配置相关类型
export interface ConfigInfo {
  configId: number;
  name: string;
  createTime: string;
  updateTime: string;
}

export interface ConfigRequest {
  configId?: number;
  name: string;
}

export interface ConfigQueryParams {
  current: number;
  size: number;
  configId?: number;
  name: string;
}

// 文件上传相关类型
export interface UploadResponse {
  key: string;
  url?: string;
  size?: number;
  type?: string;
}

// 请求选项类型
export interface RequestOptions {
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
  headers?: Record<string, string>;
  body?: any;
  timeout?: number;
  retry?: number;
  onUploadProgress?: (progressEvent: ProgressEvent) => void;
}

// 枚举类型
export enum UserRole {
  NORMAL = 0,
  ADMIN = 1,
  SUPER_ADMIN = 2
}

export enum UserStatus {
  LOCKED = 0,
  NORMAL = 1,
  DELETED = 2
}

export enum CarType {
  NEW = '1',
  USED = '2'
}

export enum CarStatus {
  NOT_LISTED = 0,
  LISTED = 1,
  SOLD = 2,
  UNLISTED = 3
}

// 汽车媒体相关类型
export interface CarMediaInfo {
  mediaId: number;
  carId: number;
  type: MediaType;
  typeName: string;
  category: MediaCategory;
  categoryName: string;
  url: string;
  createTime: string;
  updateTime: string;
}

export interface CarMediaRequest {
  carId: number;
  mediaList: {
    type: MediaType;
    category: MediaCategory;
    url: string;
  }[];
}

export interface CarMediaUploadRequest {
  carId: number;
  files: File[];
  type: MediaType;
  category: MediaCategory;
}

// 工具类型
export type ApiResponse<T = any> = BaseResponse<T>;

